<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('公文处理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>公文标题：</label>
                                <input type="text" name="arrangeTitle"/>
                            </li>
                            <li>
                                <label>接收人：</label>
                                <input type="text" name="receiveUser"/>
                            </li>
                            <li>
                                <label>接收单位：</label>
                                <input type="text" name="receiveDept"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select name="status" th:with="type=${@dict.getType('document_progress_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="document:progress:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var receiveFlag = [[${@permission.hasPermi('document:progress:receive')}]];
        var removeFlag = [[${@permission.hasPermi('document:progress:remove')}]];
        var statusDatas = [[${@dict.getType('document_progress_status')}]];
        var prefix = ctx + "document/progress";
        var filePrefix = ctx + "document/file";

        $(function() {
            var options = {
                url: prefix + "/list",
                removeUrl: prefix + "/remove",
                modalName: "公文处理",
                sortName: "createTime",
		        sortOrder: "desc",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'progressId',
                    title: '公文处理ID',
                    visible: false
                },
                {
                    field: 'arrangeTitle',
                    title: '公文标题',
                },
                {
                    field: 'arrangeId',
                    title: '工作安排id',
                    visible: false
                },
                {
                    field: 'receiveUserId',
                    title: '接收人id',
                    visible: false
                },
                {
                    field: 'receiveUser',
                    title: '接收人'
                },
                {
                    field: 'receiveDept',
                    title: '接收单位'
                },

                {
                    field: 'receiveDate',
                    title: '接收日期'
                },
                {
                    field: 'endDate',
                    title: '截止日期'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'receiptInfo',
                    title: '回执信息'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + receiveFlag + '" href="javascript:void(0)" onclick="view_detail(\'' + row.arrangeId + "#" + row.receiveUserId + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="sms_prompt(\'' + row.progressId + '\')"><i class="fa fa-remove"></i>短信提示</a>');
                        return actions.join('');
                    }
                }]
            };
            console.log(options);
            $.table.init(options);
            $.table.hideColumn("receiveUserId");
        });

        function view_detail(arrangeId){
            // console.log("receiveUserId:" + arrangeId);
            var split = arrangeId.split("#");
            var url = filePrefix + "/detail/" + split[0] + "/" + split[1];
            // var url = prefix + "/detail/" + split[0];
            console.log("receiveUserId:" + url);
           /* var options = {
                    title: "详情",
                    url: url,
                    full: true,
                    btn: ['关闭'],
                    yes: function (index, layero) {
                        layer.close(index);
                    }
                };*/
            $.modal.openTab("详情", url);
            // $.modal.openOptions(options);
        }

        function sms_prompt(progressId){
            var url = prefix+"/smsPrompt"
            $.operate.post(url, { "progressId": progressId });
        }
    </script>
</body>
</html>